import 'virtual:svg-icons-register';
import 'element-plus/es/components/message/style/css';
import { createApp } from 'vue';
import App from './App.vue';
import router from './router/index';
import store from './store/store';

// 刷新状态器重新赋值
store.replaceState(
  Object.assign({}, store.state, JSON.parse(localStorage.getItem('estoreConsole_vuex'))),
);

import EST_ENV from '@/config/env.js';
if (!EST_ENV.getEnv()) EST_ENV.initEnvData();

// 引入element-plus, 样式由vite AutoImport引入
// importStyle配置为sass后，可以在src/assets/css/var.scss改写$colors主题样式
import ElementPlus from 'element-plus';
//import 'element-plus/dist/index.css';
import zhCN from 'element-plus/es/locale/lang/zh-cn';

import './assets/css/common.scss';
// 全局注册所有图片@element-plus/icons-vue
import * as ElementPlusIconsVue from '@element-plus/icons-vue';
// 引入rem.js
// import './static/js/rem.js';
// 全局路由守卫
import './permission.js';

const app = createApp(App);

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component('ElIcon' + key, component);
  app.component(key, component);
}

app
  //
  .use(ElementPlus, { locale: zhCN })
  .use(store)
  .use(router);

app.mount('#app');
